const Koa = require('koa')
const { koaBody } = require('koa-body')
const loginroute = require('./router/login')
const mainloginroute = require('./router/main/mainlogin')
const mainbanderroute = require('./router/main/bander')
const shopperuserrouter = require('./router/shopper/login')
const shopperreqrouter = require('./router/shopper/request')
const maingetuserrouter = require('./router/main/getuser')
const maingetshoprouter = require('./router/main/getshop')
const usershoperrouter = require('./router/shoper')
const lxrouter = require('./router/lx')
const userrouter = require('./router/user')
const produrouter = require("./router/produ")
const lovesrouter = require("./router/loves")
const orderrouter = require("./router/order")
const shoppershopperrouter = require("./router/shopper/shoper")
const productshopperrouter = require("./router/shopper/product")
const ordershopperrouter = require("./router/shopper/order")
const ordermainrouter = require("./router/main/order")
const productmainrouter = require("./router/main/product")


////////////////////////////////////
const static = require('koa-static')
const path = require('path')
const app = new Koa()
app.use(static(path.resolve(__dirname, '../public')))
app.use(koaBody({
    multipart: true,
    formidable: {
        uploadDir: path.join(__dirname, '../public/img'),
        keepExtensions: true,
    }
}))
/////////////////////////////////////////////////////
app.use(loginroute.routes())
app.use(mainloginroute.routes())
app.use(mainbanderroute.routes())
app.use(shopperuserrouter.routes())
app.use(shopperreqrouter.routes())
app.use(maingetuserrouter.routes())
app.use(maingetshoprouter.routes())
app.use(lxrouter.routes())
app.use(userrouter.routes())
app.use(usershoperrouter.routes())
app.use(produrouter.routes())
app.use(lovesrouter.routes())
app.use(orderrouter.routes())
app.use(shoppershopperrouter.routes())
app.use(productshopperrouter.routes())
app.use(ordershopperrouter.routes())
app.use(ordermainrouter.routes())
app.use(productmainrouter.routes())
///////////////////////////////////////////////////////////
app.listen('3006', () => {
    console.log('server is running on http://localhost:3006')
})
/////////////////////////////////////////////////////////
// const NodeMediaServer = require('node-media-server');

// const config = {
//     rtmp: {
//         port: 1935,
//         chunk_size: 60000,
//         gop_cache: true,
//         ping: 30,
//         ping_timeout: 60
//     },
//     http: {
//         port: 8000,
//         allow_origin: '*'
//     }
// };

// const nms = new NodeMediaServer(config);



// nms.run();
/////////////////////////////////////////////////////////